public final class Model extends SceneModel {
	public static boolean aBoolean1684;
	private static boolean[] aBooleanArray1663 = new boolean[4096];
	private static boolean[] aBooleanArray1664 = new boolean[4096];
	public static final Model model = new Model();
	private static int anInt1681;
	private static int anInt1682;
	private static int anInt1683;
	public static int anInt1685;
	public static int anInt1686;
	public static int anInt1687;
	private static int[] anIntArray1622 = new int[2000];
	private static int[] anIntArray1623 = new int[2000];
	private static int[] anIntArray1624 = new int[2000];
	private static int[] anIntArray1625 = new int[2000];
	private static int[] anIntArray1665 = new int[4096];
	private static int[] anIntArray1666 = new int[4096];
	private static int[] zoom = new int[4096];// anIntArray1667
	private static int[] anIntArray1668 = new int[4096];
	private static int[] anIntArray1669 = new int[4096];
	private static int[] anIntArray1670 = new int[4096];
	private static int[] anIntArray1671 = new int[1500];
	private static int[] anIntArray1673 = new int[12];
	private static int[] anIntArray1675 = new int[2000];
	private static int[] anIntArray1676 = new int[2000];
	private static int[] anIntArray1677 = new int[12];
	private static final int[] anIntArray1678 = new int[10];
	private static final int[] anIntArray1679 = new int[10];
	private static final int[] anIntArray1680 = new int[10];
	public static final int[] anIntArray1688 = new int[1000];
	private static int[][] anIntArrayArray1672 = new int[1500][512];
	private static int[][] anIntArrayArray1674 = new int[12][2000];
	private static FileRequester fileRequester;
	private static ModelHeader[] cachedModelHeaders;
	public static int sineTable[];
	public static int cosineTable[];
	private static int[] invertedPallete;// modelIntArray3
	private static int[] invertedColors;// modelIntArray4
	static {
		Model.sineTable = Renderer3D.sineTable;
		Model.cosineTable = Renderer3D.cosineTable;
		Model.invertedPallete = Renderer3D.invertedPalette;
		Model.invertedColors = Renderer3D.invertedColors;
	}

	public static void method459(int id, FileRequester fileRequester) {
		Model.cachedModelHeaders = new ModelHeader[id];
		Model.fileRequester = fileRequester;
	}

	private void readModel(int id) {
		try {
			aBoolean1659 = false;
			ModelHeader modelHeader = Model.cachedModelHeaders[id];
			vertexCount = modelHeader.vertexCount;
			triangleCount = modelHeader.triangleCount;
			texturedTriangleCount = modelHeader.texturedTriangleCount;
			verticesX = new int[vertexCount];
			verticesY = new int[vertexCount];
			verticesZ = new int[vertexCount];
			facePointsA = new int[triangleCount];
			facePointsB = new int[triangleCount];
			facePointsC = new int[triangleCount];
			texturedFacePointsA = new int[texturedTriangleCount];
			texturedFacePointsB = new int[texturedTriangleCount];
			texturedFacePointsC = new int[texturedTriangleCount];
			if (modelHeader.vertexSkinOffset >= 0) {
				vertexSkins = new int[vertexCount];
			}
			if (modelHeader.triangleFaceTypeOffset >= 0) {
				renderTypes = new int[triangleCount];
			}
			if (modelHeader.trianglePriorityOffset >= 0) {
				priorities = new int[triangleCount];
			} else {
				anInt1641 = -modelHeader.trianglePriorityOffset - 1;
			}
			if (modelHeader.triangleTransparencyOffset >= 0) {
				alpha = new int[triangleCount];
			}
			if (modelHeader.triangleSkinningOffset >= 0) {
				textureSkins = new int[triangleCount];
			}
			colors = new int[triangleCount];
			Packet packet = new Packet(modelHeader.buffer);
			packet.offset = modelHeader.vertexModOffset;
			Packet stream_1 = new Packet(modelHeader.buffer);
			stream_1.offset = modelHeader.vertexXOffset;
			Packet stream_2 = new Packet(modelHeader.buffer);
			stream_2.offset = modelHeader.vertexYOffset;
			Packet stream_3 = new Packet(modelHeader.buffer);
			stream_3.offset = modelHeader.vertexZOffset;
			Packet stream_4 = new Packet(modelHeader.buffer);
			stream_4.offset = modelHeader.vertexSkinOffset;
			int k = 0;
			int l = 0;
			int i1 = 0;
			for (int j1 = 0; j1 < vertexCount; j1++) {
				int k1 = packet.getUnsignedByte();
				int i2 = 0;
				if ((k1 & 1) != 0) {
					i2 = stream_1.getUnsignedSmart();
				}
				int k2 = 0;
				if ((k1 & 2) != 0) {
					k2 = stream_2.getUnsignedSmart();
				}
				int i3 = 0;
				if ((k1 & 4) != 0) {
					i3 = stream_3.getUnsignedSmart();
				}
				verticesX[j1] = k + i2;
				verticesY[j1] = l + k2;
				verticesZ[j1] = i1 + i3;
				k = verticesX[j1];
				l = verticesY[j1];
				i1 = verticesZ[j1];
				if (vertexSkins != null) {
					vertexSkins[j1] = stream_4.getUnsignedByte();
				}
			}
			packet.offset = modelHeader.triangleColorOffset;
			stream_1.offset = modelHeader.triangleFaceTypeOffset;
			stream_2.offset = modelHeader.trianglePriorityOffset;
			stream_3.offset = modelHeader.triangleTransparencyOffset;
			stream_4.offset = modelHeader.triangleSkinningOffset;
			for (int l1 = 0; l1 < triangleCount; l1++) {
				colors[l1] = packet.getUnsignedShort();
				if (renderTypes != null) {
					renderTypes[l1] = stream_1.getUnsignedByte();
				}
				if (priorities != null) {
					priorities[l1] = stream_2.getUnsignedByte();
				}
				if (alpha != null) {
					alpha[l1] = stream_3.getUnsignedByte();
				}
				if (textureSkins != null) {
					textureSkins[l1] = stream_4.getUnsignedByte();
				}
			}
			packet.offset = modelHeader.triangleVertexPointOffset;
			stream_1.offset = modelHeader.triangleMeshLinkOffset;
			int j2 = 0;
			int l2 = 0;
			int j3 = 0;
			int k3 = 0;
			for (int l3 = 0; l3 < triangleCount; l3++) {
				int i4 = stream_1.getUnsignedByte();
				if (i4 == 1) {
					j2 = packet.getUnsignedSmart() + k3;
					k3 = j2;
					l2 = packet.getUnsignedSmart() + k3;
					k3 = l2;
					j3 = packet.getUnsignedSmart() + k3;
					k3 = j3;
					facePointsA[l3] = j2;
					facePointsB[l3] = l2;
					facePointsC[l3] = j3;
				}
				if (i4 == 2) {
					l2 = j3;
					j3 = packet.getUnsignedSmart() + k3;
					k3 = j3;
					facePointsA[l3] = j2;
					facePointsB[l3] = l2;
					facePointsC[l3] = j3;
				}
				if (i4 == 3) {
					j2 = j3;
					j3 = packet.getUnsignedSmart() + k3;
					k3 = j3;
					facePointsA[l3] = j2;
					facePointsB[l3] = l2;
					facePointsC[l3] = j3;
				}
				if (i4 == 4) {
					int k4 = j2;
					j2 = l2;
					l2 = k4;
					j3 = packet.getUnsignedSmart() + k3;
					k3 = j3;
					facePointsA[l3] = j2;
					facePointsB[l3] = l2;
					facePointsC[l3] = j3;
				}
			}
			packet.offset = modelHeader.triangleTextureOffset;
			for (int j4 = 0; j4 < texturedTriangleCount; j4++) {
				texturedFacePointsA[j4] = packet.getUnsignedShort();
				texturedFacePointsB[j4] = packet.getUnsignedShort();
				texturedFacePointsC[j4] = packet.getUnsignedShort();
			}
		} catch (Exception e) {
		}
	}

	public static void method460(byte[] data, int id) {
		boolean newFormat = (data[data.length - 1] == -1) && (data[data.length - 2] == -1);
		Packet buffer = new Packet(data);
		buffer.offset = data.length - (!newFormat ? 18 : 23);
		ModelHeader modelHeader = Model.cachedModelHeaders[id] = new ModelHeader();
		modelHeader.buffer = data;
		modelHeader.vertexCount = buffer.getUnsignedShort();
		modelHeader.triangleCount = buffer.getUnsignedShort();
		modelHeader.texturedTriangleCount = buffer.getUnsignedByte();
		int k = buffer.getUnsignedByte();
		int l = buffer.getUnsignedByte();
		int i1 = buffer.getUnsignedByte();
		int j1 = buffer.getUnsignedByte();
		int k1 = buffer.getUnsignedByte();
		if (newFormat) {
		}
		int l1 = buffer.getUnsignedShort();
		int i2 = buffer.getUnsignedShort();
		int j2 = buffer.getUnsignedShort();
		int k2 = buffer.getUnsignedShort();
		int l2 = 0;
		modelHeader.vertexModOffset = l2;
		l2 += modelHeader.vertexCount;
		modelHeader.triangleMeshLinkOffset = l2;
		l2 += modelHeader.triangleCount;
		modelHeader.trianglePriorityOffset = l2;
		if (l == 255) {
			l2 += modelHeader.triangleCount;
		} else {
			modelHeader.trianglePriorityOffset = -l - 1;
		}
		modelHeader.triangleSkinningOffset = l2;
		if (j1 == 1) {
			l2 += modelHeader.triangleCount;
		} else {
			modelHeader.triangleSkinningOffset = -1;
		}
		modelHeader.triangleFaceTypeOffset = l2;
		if (k == 1) {
			l2 += modelHeader.triangleCount;
		} else {
			modelHeader.triangleFaceTypeOffset = -1;
		}
		modelHeader.vertexSkinOffset = l2;
		if (k1 == 1) {
			l2 += modelHeader.vertexCount;
		} else {
			modelHeader.vertexSkinOffset = -1;
		}
		modelHeader.triangleTransparencyOffset = l2;
		if (i1 == 1) {
			l2 += modelHeader.triangleCount;
		} else {
			modelHeader.triangleTransparencyOffset = -1;
		}
		modelHeader.triangleVertexPointOffset = l2;
		l2 += k2;
		modelHeader.triangleColorOffset = l2;
		l2 += modelHeader.triangleCount * 2;
		modelHeader.triangleTextureOffset = l2;
		l2 += modelHeader.texturedTriangleCount * 6;
		modelHeader.vertexXOffset = l2;
		l2 += l1;
		modelHeader.vertexYOffset = l2;
		l2 += i2;
		modelHeader.vertexZOffset = l2;
		l2 += j2;
	}

	public static void method461(int j) {
		Model.cachedModelHeaders[j] = null;
	}

	public static Model method462(int j) {
		if (Model.cachedModelHeaders == null) {
			return null;
		}
		ModelHeader modelHeader = Model.cachedModelHeaders[j];
		if (modelHeader == null) {
			Model.fileRequester.method548(j);
			return null;
		} else {
			return new Model(j);
		}
	}

	public static boolean method463(int i) {
		if (Model.cachedModelHeaders == null) {
			return false;
		}
		ModelHeader modelHeader = Model.cachedModelHeaders[i];
		if (modelHeader == null) {
			Model.fileRequester.method548(i);
			return false;
		} else {
			return true;
		}
	}

	private static int method481(int i, int j, int k) {
		if ((k & 2) == 2) {
			if (j < 0) {
				j = 0;
			} else if (j > 127) {
				j = 127;
			}
			j = 127 - j;
			return j;
		}
		j = j * (i & 0x7f) >> 7;
		if (j < 2) {
			j = 2;
		} else if (j > 126) {
			j = 126;
		}
		return (i & 0xff80) + j;
	}

	public static void nullLoader() {
		Model.cachedModelHeaders = null;
		Model.aBooleanArray1663 = null;
		Model.aBooleanArray1664 = null;
		Model.anIntArray1665 = null;
		Model.anIntArray1666 = null;
		Model.zoom = null;
		Model.anIntArray1668 = null;
		Model.anIntArray1669 = null;
		Model.anIntArray1670 = null;
		Model.anIntArray1671 = null;
		Model.anIntArrayArray1672 = null;
		Model.anIntArray1673 = null;
		Model.anIntArrayArray1674 = null;
		Model.anIntArray1675 = null;
		Model.anIntArray1676 = null;
		Model.anIntArray1677 = null;
		Model.sineTable = null;
		Model.cosineTable = null;
		Model.invertedPallete = null;
		Model.invertedColors = null;
	}
	public boolean aBoolean1659;
	Vertex offsets[];
	public int vertexCount;
	public int triangleCount;
	private int anInt1641;
	private int texturedTriangleCount;// anInt1642
	public int anInt1646;
	public int anInt1647;
	public int anInt1648;
	public int anInt1649;
	public int anInt1650;
	public int anInt1651;
	private int anInt1652;
	private int anInt1653;
	public int anInt1654;
	public int verticesX[];
	public int verticesY[];
	public int verticesZ[];
	public int facePointsA[];
	public int facePointsB[];
	public int facePointsC[];
	private int[] hsl1;
	private int[] hsl2;
	private int[] hsl3;
	public int renderTypes[];// anIntArray1637[]
	private int[] priorities;// anIntArray1638
	private int[] alpha;// anIntArray1639
	public int colors[];// anIntArray1640[]
	private int[] texturedFacePointsA;// anIntArray1643
	private int[] texturedFacePointsB;// anIntArray1644
	private int[] texturedFacePointsC;// anIntArray1645
	private int[] textureSkins;// anIntArray1655
	private int[] vertexSkins;// anIntArray1656
	public int anIntArrayArray1657[][];
	public int anIntArrayArray1658[][];

	private Model() {
		aBoolean1659 = false;
	}

	public Model(boolean flag, boolean flag1, boolean flag2, Model model) {
		aBoolean1659 = false;
		vertexCount = model.vertexCount;
		triangleCount = model.triangleCount;
		texturedTriangleCount = model.texturedTriangleCount;
		if (flag2) {
			verticesX = model.verticesX;
			verticesY = model.verticesY;
			verticesZ = model.verticesZ;
		} else {
			verticesX = new int[vertexCount];
			verticesY = new int[vertexCount];
			verticesZ = new int[vertexCount];
			for (int j = 0; j < vertexCount; j++) {
				verticesX[j] = model.verticesX[j];
				verticesY[j] = model.verticesY[j];
				verticesZ[j] = model.verticesZ[j];
			}
		}
		if (flag) {
			colors = model.colors;
		} else {
			colors = new int[triangleCount];
			System.arraycopy(model.colors, 0, colors, 0, triangleCount);
		}
		if (flag1) {
			alpha = model.alpha;
		} else {
			alpha = new int[triangleCount];
			if (model.alpha == null) {
				for (int l = 0; l < triangleCount; l++) {
					alpha[l] = 0;
				}
			} else {
				System.arraycopy(model.alpha, 0, alpha, 0, triangleCount);
			}
		}
		textureSkins = model.textureSkins;
		vertexSkins = model.vertexSkins;
		renderTypes = model.renderTypes;
		facePointsA = model.facePointsA;
		facePointsB = model.facePointsB;
		facePointsC = model.facePointsC;
		priorities = model.priorities;
		anInt1641 = model.anInt1641;
		texturedFacePointsA = model.texturedFacePointsA;
		texturedFacePointsB = model.texturedFacePointsB;
		texturedFacePointsC = model.texturedFacePointsC;
	}

	public Model(boolean flag, boolean flag1, Model model) {
		aBoolean1659 = false;
		vertexCount = model.vertexCount;
		triangleCount = model.triangleCount;
		texturedTriangleCount = model.texturedTriangleCount;
		if (flag) {
			verticesY = new int[vertexCount];
			System.arraycopy(model.verticesY, 0, verticesY, 0, vertexCount);
		} else {
			verticesY = model.verticesY;
		}
		if (flag1) {
			hsl1 = new int[triangleCount];
			hsl2 = new int[triangleCount];
			hsl3 = new int[triangleCount];
			for (int k = 0; k < triangleCount; k++) {
				hsl1[k] = model.hsl1[k];
				hsl2[k] = model.hsl2[k];
				hsl3[k] = model.hsl3[k];
			}
			renderTypes = new int[triangleCount];
			if (model.renderTypes == null) {
				for (int l = 0; l < triangleCount; l++) {
					renderTypes[l] = 0;
				}
			} else {
				System.arraycopy(model.renderTypes, 0, renderTypes, 0, triangleCount);
			}
			super.vertices = new Vertex[vertexCount];
			for (int j1 = 0; j1 < vertexCount; j1++) {
				Vertex vertex = super.vertices[j1] = new Vertex();
				Vertex class33_1 = model.vertices[j1];
				vertex.anInt602 = class33_1.anInt602;
				vertex.anInt603 = class33_1.anInt603;
				vertex.anInt604 = class33_1.anInt604;
				vertex.anInt605 = class33_1.anInt605;
			}
			offsets = model.offsets;
		} else {
			hsl1 = model.hsl1;
			hsl2 = model.hsl2;
			hsl3 = model.hsl3;
			renderTypes = model.renderTypes;
		}
		verticesX = model.verticesX;
		verticesZ = model.verticesZ;
		colors = model.colors;
		alpha = model.alpha;
		priorities = model.priorities;
		anInt1641 = model.anInt1641;
		facePointsA = model.facePointsA;
		facePointsB = model.facePointsB;
		facePointsC = model.facePointsC;
		texturedFacePointsA = model.texturedFacePointsA;
		texturedFacePointsB = model.texturedFacePointsB;
		texturedFacePointsC = model.texturedFacePointsC;
		super.modelHeight = model.modelHeight;
		anInt1651 = model.anInt1651;
		anInt1650 = model.anInt1650;
		anInt1653 = model.anInt1653;
		anInt1652 = model.anInt1652;
		anInt1646 = model.anInt1646;
		anInt1648 = model.anInt1648;
		anInt1649 = model.anInt1649;
		anInt1647 = model.anInt1647;
	}

	private Model(int modelId) {
		readModel(modelId);
	}

	public Model(int amount, Model models[]) {
		aBoolean1659 = false;
		boolean flag = false;
		boolean flag1 = false;
		boolean flag2 = false;
		boolean flag3 = false;
		vertexCount = 0;
		triangleCount = 0;
		texturedTriangleCount = 0;
		anInt1641 = -1;
		for (int k = 0; k < amount; k++) {
			Model model = models[k];
			if (model != null) {
				vertexCount += model.vertexCount;
				triangleCount += model.triangleCount;
				texturedTriangleCount += model.texturedTriangleCount;
				flag |= model.renderTypes != null;
				if (model.priorities != null) {
					flag1 = true;
				} else {
					if (anInt1641 == -1) {
						anInt1641 = model.anInt1641;
					}
					if (anInt1641 != model.anInt1641) {
						flag1 = true;
					}
				}
				flag2 |= model.alpha != null;
				flag3 |= model.vertexSkins != null;
			}
		}
		verticesX = new int[vertexCount];
		verticesY = new int[vertexCount];
		verticesZ = new int[vertexCount];
		textureSkins = new int[vertexCount];
		facePointsA = new int[triangleCount];
		facePointsB = new int[triangleCount];
		facePointsC = new int[triangleCount];
		texturedFacePointsA = new int[texturedTriangleCount];
		texturedFacePointsB = new int[texturedTriangleCount];
		texturedFacePointsC = new int[texturedTriangleCount];
		if (flag) {
			renderTypes = new int[triangleCount];
		}
		if (flag1) {
			priorities = new int[triangleCount];
		}
		if (flag2) {
			alpha = new int[triangleCount];
		}
		if (flag3) {
			vertexSkins = new int[triangleCount];
		}
		colors = new int[triangleCount];
		vertexCount = 0;
		triangleCount = 0;
		texturedTriangleCount = 0;
		int l = 0;
		for (int i1 = 0; i1 < amount; i1++) {
			Model model_1 = models[i1];
			if (model_1 != null) {
				for (int j1 = 0; j1 < model_1.triangleCount; j1++) {
					if (flag) {
						if (model_1.renderTypes == null) {
							renderTypes[triangleCount] = 0;
						} else {
							int k1 = model_1.renderTypes[j1];
							if ((k1 & 2) == 2) {
								k1 += l << 2;
							}
							renderTypes[triangleCount] = k1;
						}
					}
					if (flag1) {
						if (model_1.priorities == null) {
							priorities[triangleCount] = model_1.anInt1641;
						} else {
							priorities[triangleCount] = model_1.priorities[j1];
						}
					}
					if (flag2) {
						if (model_1.alpha == null) {
							alpha[triangleCount] = 0;
						} else {
							alpha[triangleCount] = model_1.alpha[j1];
						}
					}
					if (flag3 && (model_1.vertexSkins != null)) {
						vertexSkins[triangleCount] = model_1.vertexSkins[j1];
					}
					colors[triangleCount] = model_1.colors[j1];
					facePointsA[triangleCount] = method465(model_1, model_1.facePointsA[j1]);
					facePointsB[triangleCount] = method465(model_1, model_1.facePointsB[j1]);
					facePointsC[triangleCount] = method465(model_1, model_1.facePointsC[j1]);
					triangleCount++;
				}
				for (int l1 = 0; l1 < model_1.texturedTriangleCount; l1++) {
					texturedFacePointsA[texturedTriangleCount] = method465(model_1, model_1.texturedFacePointsA[l1]);
					texturedFacePointsB[texturedTriangleCount] = method465(model_1, model_1.texturedFacePointsB[l1]);
					texturedFacePointsC[texturedTriangleCount] = method465(model_1, model_1.texturedFacePointsC[l1]);
					texturedTriangleCount++;
				}
				l += model_1.texturedTriangleCount;
			}
		}
	}

	public Model(Model models[]) {
		int i = 2;
		aBoolean1659 = false;
		boolean flag1 = false;
		boolean flag2 = false;
		boolean flag3 = false;
		boolean flag4 = false;
		vertexCount = 0;
		triangleCount = 0;
		texturedTriangleCount = 0;
		anInt1641 = -1;
		for (int k = 0; k < i; k++) {
			Model model = models[k];
			if (model != null) {
				vertexCount += model.vertexCount;
				triangleCount += model.triangleCount;
				texturedTriangleCount += model.texturedTriangleCount;
				flag1 |= model.renderTypes != null;
				if (model.priorities != null) {
					flag2 = true;
				} else {
					if (anInt1641 == -1) {
						anInt1641 = model.anInt1641;
					}
					if (anInt1641 != model.anInt1641) {
						flag2 = true;
					}
				}
				flag3 |= model.alpha != null;
				flag4 |= model.colors != null;
			}
		}
		verticesX = new int[vertexCount];
		verticesY = new int[vertexCount];
		verticesZ = new int[vertexCount];
		facePointsA = new int[triangleCount];
		facePointsB = new int[triangleCount];
		facePointsC = new int[triangleCount];
		hsl1 = new int[triangleCount];
		hsl2 = new int[triangleCount];
		hsl3 = new int[triangleCount];
		texturedFacePointsA = new int[texturedTriangleCount];
		texturedFacePointsB = new int[texturedTriangleCount];
		texturedFacePointsC = new int[texturedTriangleCount];
		if (flag1) {
			renderTypes = new int[triangleCount];
		}
		if (flag2) {
			priorities = new int[triangleCount];
		}
		if (flag3) {
			alpha = new int[triangleCount];
		}
		if (flag4) {
			colors = new int[triangleCount];
		}
		vertexCount = 0;
		triangleCount = 0;
		texturedTriangleCount = 0;
		int i1 = 0;
		for (int j1 = 0; j1 < i; j1++) {
			Model model = models[j1];
			if (model != null) {
				int k1 = vertexCount;
				for (int l1 = 0; l1 < model.vertexCount; l1++) {
					verticesX[vertexCount] = model.verticesX[l1];
					verticesY[vertexCount] = model.verticesY[l1];
					verticesZ[vertexCount] = model.verticesZ[l1];
					vertexCount++;
				}
				for (int i2 = 0; i2 < model.triangleCount; i2++) {
					facePointsA[triangleCount] = model.facePointsA[i2] + k1;
					facePointsB[triangleCount] = model.facePointsB[i2] + k1;
					facePointsC[triangleCount] = model.facePointsC[i2] + k1;
					hsl1[triangleCount] = model.hsl1[i2];
					hsl2[triangleCount] = model.hsl2[i2];
					hsl3[triangleCount] = model.hsl3[i2];
					if (flag1) {
						if (model.renderTypes == null) {
							renderTypes[triangleCount] = 0;
						} else {
							int j2 = model.renderTypes[i2];
							if ((j2 & 2) == 2) {
								j2 += i1 << 2;
							}
							renderTypes[triangleCount] = j2;
						}
					}
					if (flag2) {
						if (model.priorities == null) {
							priorities[triangleCount] = model.anInt1641;
						} else {
							priorities[triangleCount] = model.priorities[i2];
						}
					}
					if (flag3) {
						if (model.alpha == null) {
							alpha[triangleCount] = 0;
						} else {
							alpha[triangleCount] = model.alpha[i2];
						}
					}
					if (flag4 && (model.colors != null)) {
						colors[triangleCount] = model.colors[i2];
					}
					triangleCount++;
				}
				for (int k2 = 0; k2 < model.texturedTriangleCount; k2++) {
					texturedFacePointsA[texturedTriangleCount] = model.texturedFacePointsA[k2] + k1;
					texturedFacePointsB[texturedTriangleCount] = model.texturedFacePointsB[k2] + k1;
					texturedFacePointsC[texturedTriangleCount] = model.texturedFacePointsC[k2] + k1;
					texturedTriangleCount++;
				}
				i1 += model.texturedTriangleCount;
			}
		}
		method466();
	}

	@Override
	public void render(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) {
		int j2 = l1 * i1 - j1 * l >> 16;
		int k2 = k1 * j + j2 * k >> 16;
		int l2 = anInt1650 * k >> 16;
		int i3 = k2 + l2;
		if ((i3 <= 50) || (k2 >= 3500)) {
			return;
		}
		int j3 = l1 * l + j1 * i1 >> 16;
		int k3 = j3 - anInt1650 << 9;
		if (k3 / i3 >= Renderer2D.middleX) {
			return;
		}
		int l3 = j3 + anInt1650 << 9;
		if (l3 / i3 <= -Renderer2D.middleX) {
			return;
		}
		int i4 = k1 * k - j2 * j >> 16;
		int j4 = anInt1650 * j >> 16;
		int k4 = i4 + j4 << 9;
		if (k4 / i3 <= -Renderer2D.centerY) {
			return;
		}
		int l4 = j4 + (super.modelHeight * k >> 16);
		int i5 = i4 - l4 << 9;
		if (i5 / i3 >= Renderer2D.centerY) {
			return;
		}
		int j5 = l2 + (super.modelHeight * j >> 16);
		boolean flag = false;
		if (k2 - j5 <= 50) {
			flag = true;
		}
		boolean flag1 = false;
		if ((i2 > 0) && Model.aBoolean1684) {
			int k5 = k2 - l2;
			if (k5 <= 50) {
				k5 = 50;
			}
			if (j3 > 0) {
				k3 /= i3;
				l3 /= k5;
			} else {
				l3 /= i3;
				k3 /= k5;
			}
			if (i4 > 0) {
				i5 /= i3;
				k4 /= k5;
			} else {
				k4 /= i3;
				i5 /= k5;
			}
			int i6 = Model.anInt1685 - Renderer3D.middleX;
			int k6 = Model.anInt1686 - Renderer3D.middleY;
			if ((i6 > k3) && (i6 < l3) && (k6 > i5) && (k6 < k4)) {
				if (aBoolean1659) {
					Model.anIntArray1688[Model.anInt1687++] = i2;
				} else {
					flag1 = true;
				}
			}
		}
		int l5 = Renderer3D.middleX;
		int j6 = Renderer3D.middleY;
		int l6 = 0;
		int i7 = 0;
		if (i != 0) {
			l6 = Model.sineTable[i];
			i7 = Model.cosineTable[i];
		}
		for (int j7 = 0; j7 < vertexCount; j7++) {
			int k7 = verticesX[j7];
			int l7 = verticesY[j7];
			int i8 = verticesZ[j7];
			if (i != 0) {
				int j8 = i8 * l6 + k7 * i7 >> 16;
				i8 = i8 * i7 - k7 * l6 >> 16;
				k7 = j8;
			}
			k7 += j1;
			l7 += k1;
			i8 += l1;
			int k8 = i8 * l + k7 * i1 >> 16;
			i8 = i8 * i1 - k7 * l >> 16;
			k7 = k8;
			k8 = l7 * k - i8 * j >> 16;
			i8 = l7 * j + i8 * k >> 16;
			l7 = k8;
			Model.zoom[j7] = i8 - k2;
			if (i8 >= 50) {
				Model.anIntArray1665[j7] = l5 + (k7 << 9) / i8;
				Model.anIntArray1666[j7] = j6 + (l7 << 9) / i8;
			} else {
				Model.anIntArray1665[j7] = -5000;
				flag = true;
			}
			if (flag || (texturedTriangleCount > 0)) {
				Model.anIntArray1668[j7] = k7;
				Model.anIntArray1669[j7] = l7;
				Model.anIntArray1670[j7] = i8;
			}
		}
		try {
			method483(flag, flag1, i2);
		} catch (Exception _ex) {
		}
	}

	public void method464(Model model, boolean flag) {
		vertexCount = model.vertexCount;
		triangleCount = model.triangleCount;
		texturedTriangleCount = model.texturedTriangleCount;
		if (Model.anIntArray1622.length < vertexCount) {
			Model.anIntArray1622 = new int[vertexCount + 100];
			Model.anIntArray1623 = new int[vertexCount + 100];
			Model.anIntArray1624 = new int[vertexCount + 100];
		}
		verticesX = Model.anIntArray1622;
		verticesY = Model.anIntArray1623;
		verticesZ = Model.anIntArray1624;
		for (int k = 0; k < vertexCount; k++) {
			verticesX[k] = model.verticesX[k];
			verticesY[k] = model.verticesY[k];
			verticesZ[k] = model.verticesZ[k];
		}
		if (flag) {
			alpha = model.alpha;
		} else {
			if (Model.anIntArray1625.length < triangleCount) {
				Model.anIntArray1625 = new int[triangleCount + 100];
			}
			alpha = Model.anIntArray1625;
			if (model.alpha == null) {
				for (int l = 0; l < triangleCount; l++) {
					alpha[l] = 0;
				}
			} else {
				System.arraycopy(model.alpha, 0, alpha, 0, triangleCount);
			}
		}
		renderTypes = model.renderTypes;
		colors = model.colors;
		priorities = model.priorities;
		anInt1641 = model.anInt1641;
		anIntArrayArray1658 = model.anIntArrayArray1658;
		anIntArrayArray1657 = model.anIntArrayArray1657;
		facePointsA = model.facePointsA;
		facePointsB = model.facePointsB;
		facePointsC = model.facePointsC;
		hsl1 = model.hsl1;
		hsl2 = model.hsl2;
		hsl3 = model.hsl3;
		texturedFacePointsA = model.texturedFacePointsA;
		texturedFacePointsB = model.texturedFacePointsB;
		texturedFacePointsC = model.texturedFacePointsC;
	}

	private int method465(Model model, int i) {
		int j = -1;
		int k = model.verticesX[i];
		int l = model.verticesY[i];
		int i1 = model.verticesZ[i];
		for (int j1 = 0; j1 < vertexCount; j1++) {
			if ((k != verticesX[j1]) || (l != verticesY[j1]) || (i1 != verticesZ[j1])) {
				continue;
			}
			j = j1;
			break;
		}
		if (j == -1) {
			verticesX[vertexCount] = k;
			verticesY[vertexCount] = l;
			verticesZ[vertexCount] = i1;
			if (model.textureSkins != null) {
				textureSkins[vertexCount] = model.textureSkins[i];
			}
			j = vertexCount++;
		}
		return j;
	}

	public void method466() {
		super.modelHeight = 0;
		anInt1650 = 0;
		anInt1651 = 0;
		for (int i = 0; i < vertexCount; i++) {
			int j = verticesX[i];
			int k = verticesY[i];
			int l = verticesZ[i];
			if (-k > super.modelHeight) {
				super.modelHeight = -k;
			}
			if (k > anInt1651) {
				anInt1651 = k;
			}
			int i1 = j * j + l * l;
			if (i1 > anInt1650) {
				anInt1650 = i1;
			}
		}
		anInt1650 = (int) (Math.sqrt(anInt1650) + 0.98999999999999999D);
		anInt1653 = (int) (Math.sqrt(anInt1650 * anInt1650 + super.modelHeight * super.modelHeight) + 0.98999999999999999D);
		anInt1652 = anInt1653 + (int) (Math.sqrt(anInt1650 * anInt1650 + anInt1651 * anInt1651) + 0.98999999999999999D);
	}

	public void method467() {
		super.modelHeight = 0;
		anInt1651 = 0;
		for (int i = 0; i < vertexCount; i++) {
			int j = verticesY[i];
			if (-j > super.modelHeight) {
				super.modelHeight = -j;
			}
			if (j > anInt1651) {
				anInt1651 = j;
			}
		}
		anInt1653 = (int) (Math.sqrt(anInt1650 * anInt1650 + super.modelHeight * super.modelHeight) + 0.98999999999999999D);
		anInt1652 = anInt1653 + (int) (Math.sqrt(anInt1650 * anInt1650 + anInt1651 * anInt1651) + 0.98999999999999999D);
	}

	private void method468() {
		super.modelHeight = 0;
		anInt1650 = 0;
		anInt1651 = 0;
		anInt1646 = 0xf423f;
		anInt1647 = 0xfff0bdc1;
		anInt1648 = 0xfffe7961;
		anInt1649 = 0x1869f;
		for (int j = 0; j < vertexCount; j++) {
			int k = verticesX[j];
			int l = verticesY[j];
			int i1 = verticesZ[j];
			if (k < anInt1646) {
				anInt1646 = k;
			}
			if (k > anInt1647) {
				anInt1647 = k;
			}
			if (i1 < anInt1649) {
				anInt1649 = i1;
			}
			if (i1 > anInt1648) {
				anInt1648 = i1;
			}
			if (-l > super.modelHeight) {
				super.modelHeight = -l;
			}
			if (l > anInt1651) {
				anInt1651 = l;
			}
			int j1 = k * k + i1 * i1;
			if (j1 > anInt1650) {
				anInt1650 = j1;
			}
		}
		anInt1650 = (int) Math.sqrt(anInt1650);
		anInt1653 = (int) Math.sqrt(anInt1650 * anInt1650 + super.modelHeight * super.modelHeight);
		anInt1652 = anInt1653 + (int) Math.sqrt(anInt1650 * anInt1650 + anInt1651 * anInt1651);
	}

	public void method469() {
		if (textureSkins != null) {
			int ai[] = new int[256];
			int j = 0;
			for (int l = 0; l < vertexCount; l++) {
				int j1 = textureSkins[l];
				ai[j1]++;
				if (j1 > j) {
					j = j1;
				}
			}
			anIntArrayArray1657 = new int[j + 1][];
			for (int k1 = 0; k1 <= j; k1++) {
				anIntArrayArray1657[k1] = new int[ai[k1]];
				ai[k1] = 0;
			}
			for (int j2 = 0; j2 < vertexCount; j2++) {
				int l2 = textureSkins[j2];
				anIntArrayArray1657[l2][ai[l2]++] = j2;
			}
			textureSkins = null;
		}
		if (vertexSkins != null) {
			int ai1[] = new int[256];
			int k = 0;
			for (int i1 = 0; i1 < triangleCount; i1++) {
				int l1 = vertexSkins[i1];
				ai1[l1]++;
				if (l1 > k) {
					k = l1;
				}
			}
			anIntArrayArray1658 = new int[k + 1][];
			for (int i2 = 0; i2 <= k; i2++) {
				anIntArrayArray1658[i2] = new int[ai1[i2]];
				ai1[i2] = 0;
			}
			for (int k2 = 0; k2 < triangleCount; k2++) {
				int i3 = vertexSkins[k2];
				anIntArrayArray1658[i3][ai1[i3]++] = k2;
			}
			vertexSkins = null;
		}
	}

	public void method470(int i) {
		if (anIntArrayArray1657 == null) {
			return;
		}
		if (i == -1) {
			return;
		}
		FrameReader frameReader = FrameReader.method531(i);
		if (frameReader == null) {
			return;
		}
		SkinList skinList = frameReader.skinList;
		Model.anInt1681 = 0;
		Model.anInt1682 = 0;
		Model.anInt1683 = 0;
		for (int k = 0; k < frameReader.anInt638; k++) {
			int l = frameReader.anIntArray639[k];
			method472(skinList.opcodes[l], skinList.anIntArrayArray343[l], frameReader.anIntArray640[k], frameReader.anIntArray641[k], frameReader.anIntArray642[k]);
		}
	}

	public void method471(int ai[], int j, int k) {
		if (k == -1) {
			return;
		}
		if ((ai == null) || (j == -1)) {
			method470(k);
			return;
		}
		FrameReader frameReader = FrameReader.method531(k);
		if (frameReader == null) {
			return;
		}
		FrameReader class36_1 = FrameReader.method531(j);
		if (class36_1 == null) {
			method470(k);
			return;
		}
		SkinList skinList = frameReader.skinList;
		Model.anInt1681 = 0;
		Model.anInt1682 = 0;
		Model.anInt1683 = 0;
		int l = 0;
		int i1 = ai[l++];
		for (int j1 = 0; j1 < frameReader.anInt638; j1++) {
			int k1;
			for (k1 = frameReader.anIntArray639[j1]; k1 > i1; i1 = ai[l++]) {
				;
			}
			if ((k1 != i1) || (skinList.opcodes[k1] == 0)) {
				method472(skinList.opcodes[k1], skinList.anIntArrayArray343[k1], frameReader.anIntArray640[j1], frameReader.anIntArray641[j1], frameReader.anIntArray642[j1]);
			}
		}
		Model.anInt1681 = 0;
		Model.anInt1682 = 0;
		Model.anInt1683 = 0;
		l = 0;
		i1 = ai[l++];
		for (int l1 = 0; l1 < class36_1.anInt638; l1++) {
			int i2;
			for (i2 = class36_1.anIntArray639[l1]; i2 > i1; i1 = ai[l++]) {
				;
			}
			if ((i2 == i1) || (skinList.opcodes[i2] == 0)) {
				method472(skinList.opcodes[i2], skinList.anIntArrayArray343[i2], class36_1.anIntArray640[l1], class36_1.anIntArray641[l1], class36_1.anIntArray642[l1]);
			}
		}
	}

	private void method472(int i, int ai[], int j, int k, int l) {
		int i1 = ai.length;
		if (i == 0) {
			int j1 = 0;
			Model.anInt1681 = 0;
			Model.anInt1682 = 0;
			Model.anInt1683 = 0;
			for (int k2 = 0; k2 < i1; k2++) {
				int l3 = ai[k2];
				if (l3 < anIntArrayArray1657.length) {
					int ai5[] = anIntArrayArray1657[l3];
					for (int j6 : ai5) {
						Model.anInt1681 += verticesX[j6];
						Model.anInt1682 += verticesY[j6];
						Model.anInt1683 += verticesZ[j6];
						j1++;
					}
				}
			}
			if (j1 > 0) {
				Model.anInt1681 = Model.anInt1681 / j1 + j;
				Model.anInt1682 = Model.anInt1682 / j1 + k;
				Model.anInt1683 = Model.anInt1683 / j1 + l;
				return;
			} else {
				Model.anInt1681 = j;
				Model.anInt1682 = k;
				Model.anInt1683 = l;
				return;
			}
		}
		if (i == 1) {
			for (int k1 = 0; k1 < i1; k1++) {
				int l2 = ai[k1];
				if (l2 < anIntArrayArray1657.length) {
					int ai1[] = anIntArrayArray1657[l2];
					for (int element : ai1) {
						int j5 = element;
						verticesX[j5] += j;
						verticesY[j5] += k;
						verticesZ[j5] += l;
					}
				}
			}
			return;
		}
		if (i == 2) {
			for (int l1 = 0; l1 < i1; l1++) {
				int i3 = ai[l1];
				if (i3 < anIntArrayArray1657.length) {
					int ai2[] = anIntArrayArray1657[i3];
					for (int element : ai2) {
						int k5 = element;
						verticesX[k5] -= Model.anInt1681;
						verticesY[k5] -= Model.anInt1682;
						verticesZ[k5] -= Model.anInt1683;
						int k6 = (j & 0xff) * 8;
						int l6 = (k & 0xff) * 8;
						int i7 = (l & 0xff) * 8;
						if (i7 != 0) {
							int j7 = Model.sineTable[i7];
							int i8 = Model.cosineTable[i7];
							int l8 = verticesY[k5] * j7 + verticesX[k5] * i8 >> 16;
							verticesY[k5] = verticesY[k5] * i8 - verticesX[k5] * j7 >> 16;
							verticesX[k5] = l8;
						}
						if (k6 != 0) {
							int k7 = Model.sineTable[k6];
							int j8 = Model.cosineTable[k6];
							int i9 = verticesY[k5] * j8 - verticesZ[k5] * k7 >> 16;
							verticesZ[k5] = verticesY[k5] * k7 + verticesZ[k5] * j8 >> 16;
							verticesY[k5] = i9;
						}
						if (l6 != 0) {
							int l7 = Model.sineTable[l6];
							int k8 = Model.cosineTable[l6];
							int j9 = verticesZ[k5] * l7 + verticesX[k5] * k8 >> 16;
							verticesZ[k5] = verticesZ[k5] * k8 - verticesX[k5] * l7 >> 16;
							verticesX[k5] = j9;
						}
						verticesX[k5] += Model.anInt1681;
						verticesY[k5] += Model.anInt1682;
						verticesZ[k5] += Model.anInt1683;
					}
				}
			}
			return;
		}
		if (i == 3) {
			for (int i2 = 0; i2 < i1; i2++) {
				int j3 = ai[i2];
				if (j3 < anIntArrayArray1657.length) {
					int ai3[] = anIntArrayArray1657[j3];
					for (int element : ai3) {
						int l5 = element;
						verticesX[l5] -= Model.anInt1681;
						verticesY[l5] -= Model.anInt1682;
						verticesZ[l5] -= Model.anInt1683;
						verticesX[l5] = (verticesX[l5] * j) / 128;
						verticesY[l5] = (verticesY[l5] * k) / 128;
						verticesZ[l5] = (verticesZ[l5] * l) / 128;
						verticesX[l5] += Model.anInt1681;
						verticesY[l5] += Model.anInt1682;
						verticesZ[l5] += Model.anInt1683;
					}
				}
			}
			return;
		}
		if ((i == 5) && (anIntArrayArray1658 != null) && (alpha != null)) {
			for (int j2 = 0; j2 < i1; j2++) {
				int k3 = ai[j2];
				if (k3 < anIntArrayArray1658.length) {
					int ai4[] = anIntArrayArray1658[k3];
					for (int element : ai4) {
						int i6 = element;
						alpha[i6] += j * 8;
						if (alpha[i6] < 0) {
							alpha[i6] = 0;
						}
						if (alpha[i6] > 255) {
							alpha[i6] = 255;
						}
					}
				}
			}
		}
	}

	public void method473() {
		for (int j = 0; j < vertexCount; j++) {
			int k = verticesX[j];
			verticesX[j] = verticesZ[j];
			verticesZ[j] = -k;
		}
	}

	public void method474(int i) {
		int k = Model.sineTable[i];
		int l = Model.cosineTable[i];
		for (int i1 = 0; i1 < vertexCount; i1++) {
			int j1 = verticesY[i1] * l - verticesZ[i1] * k >> 16;
			verticesZ[i1] = verticesY[i1] * k + verticesZ[i1] * l >> 16;
			verticesY[i1] = j1;
		}
	}

	public void method475(int i, int j, int l) {
		for (int i1 = 0; i1 < vertexCount; i1++) {
			verticesX[i1] += i;
			verticesY[i1] += j;
			verticesZ[i1] += l;
		}
	}

	public void method476(int i, int j) {
		for (int k = 0; k < triangleCount; k++) {
			if (colors[k] == i) {
				colors[k] = j;
			}
		}
	}

	public void method477() {
		for (int j = 0; j < vertexCount; j++) {
			verticesZ[j] = -verticesZ[j];
		}
		for (int k = 0; k < triangleCount; k++) {
			int l = facePointsA[k];
			facePointsA[k] = facePointsC[k];
			facePointsC[k] = l;
		}
	}

	public void method478(int i, int j, int l) {
		for (int i1 = 0; i1 < vertexCount; i1++) {
			verticesX[i1] = (verticesX[i1] * i) / 128;
			verticesY[i1] = (verticesY[i1] * l) / 128;
			verticesZ[i1] = (verticesZ[i1] * j) / 128;
		}
	}

	public void preProcess(int brightness, int shadowing, int x, int y, int z, boolean flag) {
		int j1 = (int) Math.sqrt(x * x + y * y + z * z);
		int k1 = shadowing * j1 >> 8;
		if (hsl1 == null) {// anIntArray1634
			hsl1 = new int[triangleCount];// anIntArray1630
			hsl2 = new int[triangleCount];// anIntArray1635
			hsl3 = new int[triangleCount];// anIntArray1636
		}
		if (super.vertices == null) {// aClass33Array1425
			super.vertices = new Vertex[vertexCount];// anInt1626
			for (int l1 = 0; l1 < vertexCount; l1++) {
				super.vertices[l1] = new Vertex();
			}
		}
		for (int i2 = 0; i2 < triangleCount; i2++) {
			int j2 = facePointsA[i2];// anIntArray1631
			int l2 = facePointsB[i2];// anIntArray1632
			int i3 = facePointsC[i2];// anIntArray1633
			int j3 = verticesX[l2] - verticesX[j2];// anIntArray1627
			int k3 = verticesY[l2] - verticesY[j2];// anIntArray1628
			int l3 = verticesZ[l2] - verticesZ[j2];// anIntArray1629
			int i4 = verticesX[i3] - verticesX[j2];
			int j4 = verticesY[i3] - verticesY[j2];
			int k4 = verticesZ[i3] - verticesZ[j2];
			int l4 = k3 * k4 - j4 * l3;
			int i5 = l3 * i4 - k4 * j3;
			int j5;
			for (j5 = j3 * j4 - i4 * k3; (l4 > 8192) || (i5 > 8192) || (j5 > 8192) || (l4 < -8192) || (i5 < -8192) || (j5 < -8192); j5 >>= 1) {
				l4 >>= 1;
				i5 >>= 1;
			}
			int k5 = (int) Math.sqrt(l4 * l4 + i5 * i5 + j5 * j5);
			if (k5 <= 0) {
				k5 = 1;
			}
			l4 = (l4 * 256) / k5;
			i5 = (i5 * 256) / k5;
			j5 = (j5 * 256) / k5;
			if ((renderTypes == null) || ((renderTypes[i2] & 1) == 0)) {
				Vertex class33_2 = super.vertices[j2];
				class33_2.anInt602 += l4;
				class33_2.anInt603 += i5;
				class33_2.anInt604 += j5;
				class33_2.anInt605++;
				class33_2 = super.vertices[l2];
				class33_2.anInt602 += l4;
				class33_2.anInt603 += i5;
				class33_2.anInt604 += j5;
				class33_2.anInt605++;
				class33_2 = super.vertices[i3];
				class33_2.anInt602 += l4;
				class33_2.anInt603 += i5;
				class33_2.anInt604 += j5;
				class33_2.anInt605++;
			} else {
				int l5 = brightness + (x * l4 + y * i5 + z * j5) / (k1 + k1 / 2);
				hsl1[i2] = Model.method481(colors[i2], l5, renderTypes[i2]);
			}
		}
		if (flag) {
			method480(brightness, k1, x, y, z);
		} else {
			offsets = new Vertex[vertexCount];
			for (int k2 = 0; k2 < vertexCount; k2++) {
				Vertex vertex = super.vertices[k2];
				Vertex class33_1 = offsets[k2] = new Vertex();
				class33_1.anInt602 = vertex.anInt602;
				class33_1.anInt603 = vertex.anInt603;
				class33_1.anInt604 = vertex.anInt604;
				class33_1.anInt605 = vertex.anInt605;
			}
		}
		if (flag) {
			method466();
		} else {
			method468();
		}
	}

	public void method480(int i, int j, int k, int l, int i1) {
		for (int j1 = 0; j1 < triangleCount; j1++) {
			int k1 = facePointsA[j1];
			int i2 = facePointsB[j1];
			int j2 = facePointsC[j1];
			if (renderTypes == null) {
				int i3 = colors[j1];
				Vertex vertex = super.vertices[k1];
				int k2 = i + (k * vertex.anInt602 + l * vertex.anInt603 + i1 * vertex.anInt604) / (j * vertex.anInt605);
				hsl1[j1] = Model.method481(i3, k2, 0);
				vertex = super.vertices[i2];
				k2 = i + (k * vertex.anInt602 + l * vertex.anInt603 + i1 * vertex.anInt604) / (j * vertex.anInt605);
				hsl2[j1] = Model.method481(i3, k2, 0);
				vertex = super.vertices[j2];
				k2 = i + (k * vertex.anInt602 + l * vertex.anInt603 + i1 * vertex.anInt604) / (j * vertex.anInt605);
				hsl3[j1] = Model.method481(i3, k2, 0);
			} else if ((renderTypes[j1] & 1) == 0) {
				int j3 = colors[j1];
				int k3 = renderTypes[j1];
				Vertex class33_1 = super.vertices[k1];
				int l2 = i + (k * class33_1.anInt602 + l * class33_1.anInt603 + i1 * class33_1.anInt604) / (j * class33_1.anInt605);
				hsl1[j1] = Model.method481(j3, l2, k3);
				class33_1 = super.vertices[i2];
				l2 = i + (k * class33_1.anInt602 + l * class33_1.anInt603 + i1 * class33_1.anInt604) / (j * class33_1.anInt605);
				hsl2[j1] = Model.method481(j3, l2, k3);
				class33_1 = super.vertices[j2];
				l2 = i + (k * class33_1.anInt602 + l * class33_1.anInt603 + i1 * class33_1.anInt604) / (j * class33_1.anInt605);
				hsl3[j1] = Model.method481(j3, l2, k3);
			}
		}
		super.vertices = null;
		offsets = null;
		textureSkins = null;
		vertexSkins = null;
		if (renderTypes != null) {
			for (int l1 = 0; l1 < triangleCount; l1++) {
				if ((renderTypes[l1] & 2) == 2) {
					return;
				}
			}
		}
		colors = null;
	}

	public void method482(int j, int k, int l, int i1, int j1, int k1) {
		int i = 0; // Was a parameter.
		int l1 = Renderer3D.middleX;
		int i2 = Renderer3D.middleY;
		int j2 = Model.sineTable[i];
		int k2 = Model.cosineTable[i];
		int l2 = Model.sineTable[j];
		int i3 = Model.cosineTable[j];
		int j3 = Model.sineTable[k];
		int k3 = Model.cosineTable[k];
		int l3 = Model.sineTable[l];
		int i4 = Model.cosineTable[l];
		int j4 = j1 * l3 + k1 * i4 >> 16;
		for (int k4 = 0; k4 < vertexCount; k4++) {
			int l4 = verticesX[k4];
			int i5 = verticesY[k4];
			int j5 = verticesZ[k4];
			if (k != 0) {
				int k5 = i5 * j3 + l4 * k3 >> 16;
				i5 = i5 * k3 - l4 * j3 >> 16;
				l4 = k5;
			}
			if (i != 0) {
				int l5 = i5 * k2 - j5 * j2 >> 16;
				j5 = i5 * j2 + j5 * k2 >> 16;
				i5 = l5;
			}
			if (j != 0) {
				int i6 = j5 * l2 + l4 * i3 >> 16;
				j5 = j5 * i3 - l4 * l2 >> 16;
				l4 = i6;
			}
			l4 += i1;
			i5 += j1;
			j5 += k1;
			int j6 = i5 * i4 - j5 * l3 >> 16;
			j5 = i5 * l3 + j5 * i4 >> 16;
			i5 = j6;
			Model.zoom[k4] = j5 - j4;
			Model.anIntArray1665[k4] = l1 + (l4 << 9) / j5;
			Model.anIntArray1666[k4] = i2 + (i5 << 9) / j5;
			if (texturedTriangleCount > 0) {
				Model.anIntArray1668[k4] = l4;
				Model.anIntArray1669[k4] = i5;
				Model.anIntArray1670[k4] = j5;
			}
		}
		try {
			method483(false, false, 0);
		} catch (Exception _ex) {
		}
	}

	private void method483(boolean flag, boolean flag1, int i) {
		for (int j = 0; j < anInt1652; j++) {
			Model.anIntArray1671[j] = 0;
		}
		for (int k = 0; k < triangleCount; k++) {
			if ((renderTypes == null) || (renderTypes[k] != -1)) {
				int l = facePointsA[k];
				int k1 = facePointsB[k];
				int j2 = facePointsC[k];
				int i3 = Model.anIntArray1665[l];
				int l3 = Model.anIntArray1665[k1];
				int k4 = Model.anIntArray1665[j2];
				if (flag && ((i3 == -5000) || (l3 == -5000) || (k4 == -5000))) {
					Model.aBooleanArray1664[k] = true;
					int j5 = (Model.zoom[l] + Model.zoom[k1] + Model.zoom[j2]) / 3 + anInt1653;
					Model.anIntArrayArray1672[j5][Model.anIntArray1671[j5]++] = k;
				} else {
					if (flag1 && method486(Model.anInt1685, Model.anInt1686, Model.anIntArray1666[l], Model.anIntArray1666[k1], Model.anIntArray1666[j2], i3, l3, k4)) {
						Model.anIntArray1688[Model.anInt1687++] = i;
						flag1 = false;
					}
					if ((i3 - l3) * (Model.anIntArray1666[j2] - Model.anIntArray1666[k1]) - (Model.anIntArray1666[l] - Model.anIntArray1666[k1]) * (k4 - l3) > 0) {
						Model.aBooleanArray1664[k] = false;
						Model.aBooleanArray1663[k] = (i3 < 0) || (l3 < 0) || (k4 < 0) || (i3 > Renderer2D.endX) || (l3 > Renderer2D.endX) || (k4 > Renderer2D.endX);
						int k5 = (Model.zoom[l] + Model.zoom[k1] + Model.zoom[j2]) / 3 + anInt1653;
						Model.anIntArrayArray1672[k5][Model.anIntArray1671[k5]++] = k;
					}
				}
			}
		}
		if (priorities == null) {
			for (int i1 = anInt1652 - 1; i1 >= 0; i1--) {
				int l1 = Model.anIntArray1671[i1];
				if (l1 > 0) {
					int ai[] = Model.anIntArrayArray1672[i1];
					for (int j3 = 0; j3 < l1; j3++) {
						method484(ai[j3]);
					}
				}
			}
			return;
		}
		for (int j1 = 0; j1 < 12; j1++) {
			Model.anIntArray1673[j1] = 0;
			Model.anIntArray1677[j1] = 0;
		}
		for (int i2 = anInt1652 - 1; i2 >= 0; i2--) {
			int k2 = Model.anIntArray1671[i2];
			if (k2 > 0) {
				int ai1[] = Model.anIntArrayArray1672[i2];
				for (int i4 = 0; i4 < k2; i4++) {
					int l4 = ai1[i4];
					int l5 = priorities[l4];
					int j6 = Model.anIntArray1673[l5]++;
					Model.anIntArrayArray1674[l5][j6] = l4;
					if (l5 < 10) {
						Model.anIntArray1677[l5] += i2;
					} else if (l5 == 10) {
						Model.anIntArray1675[j6] = i2;
					} else {
						Model.anIntArray1676[j6] = i2;
					}
				}
			}
		}
		int l2 = 0;
		if ((Model.anIntArray1673[1] > 0) || (Model.anIntArray1673[2] > 0)) {
			l2 = (Model.anIntArray1677[1] + Model.anIntArray1677[2]) / (Model.anIntArray1673[1] + Model.anIntArray1673[2]);
		}
		int k3 = 0;
		if ((Model.anIntArray1673[3] > 0) || (Model.anIntArray1673[4] > 0)) {
			k3 = (Model.anIntArray1677[3] + Model.anIntArray1677[4]) / (Model.anIntArray1673[3] + Model.anIntArray1673[4]);
		}
		int j4 = 0;
		if ((Model.anIntArray1673[6] > 0) || (Model.anIntArray1673[8] > 0)) {
			j4 = (Model.anIntArray1677[6] + Model.anIntArray1677[8]) / (Model.anIntArray1673[6] + Model.anIntArray1673[8]);
		}
		int i6 = 0;
		int k6 = Model.anIntArray1673[10];
		int ai2[] = Model.anIntArrayArray1674[10];
		int ai3[] = Model.anIntArray1675;
		if (i6 == k6) {
			i6 = 0;
			k6 = Model.anIntArray1673[11];
			ai2 = Model.anIntArrayArray1674[11];
			ai3 = Model.anIntArray1676;
		}
		int i5;
		if (i6 < k6) {
			i5 = ai3[i6];
		} else {
			i5 = -1000;
		}
		for (int l6 = 0; l6 < 10; l6++) {
			while ((l6 == 0) && (i5 > l2)) {
				method484(ai2[i6++]);
				if ((i6 == k6) && (ai2 != Model.anIntArrayArray1674[11])) {
					i6 = 0;
					k6 = Model.anIntArray1673[11];
					ai2 = Model.anIntArrayArray1674[11];
					ai3 = Model.anIntArray1676;
				}
				if (i6 < k6) {
					i5 = ai3[i6];
				} else {
					i5 = -1000;
				}
			}
			while ((l6 == 3) && (i5 > k3)) {
				method484(ai2[i6++]);
				if ((i6 == k6) && (ai2 != Model.anIntArrayArray1674[11])) {
					i6 = 0;
					k6 = Model.anIntArray1673[11];
					ai2 = Model.anIntArrayArray1674[11];
					ai3 = Model.anIntArray1676;
				}
				if (i6 < k6) {
					i5 = ai3[i6];
				} else {
					i5 = -1000;
				}
			}
			while ((l6 == 5) && (i5 > j4)) {
				method484(ai2[i6++]);
				if ((i6 == k6) && (ai2 != Model.anIntArrayArray1674[11])) {
					i6 = 0;
					k6 = Model.anIntArray1673[11];
					ai2 = Model.anIntArrayArray1674[11];
					ai3 = Model.anIntArray1676;
				}
				if (i6 < k6) {
					i5 = ai3[i6];
				} else {
					i5 = -1000;
				}
			}
			int i7 = Model.anIntArray1673[l6];
			int ai4[] = Model.anIntArrayArray1674[l6];
			for (int j7 = 0; j7 < i7; j7++) {
				method484(ai4[j7]);
			}
		}
		while (i5 != -1000) {
			method484(ai2[i6++]);
			if ((i6 == k6) && (ai2 != Model.anIntArrayArray1674[11])) {
				i6 = 0;
				ai2 = Model.anIntArrayArray1674[11];
				k6 = Model.anIntArray1673[11];
				ai3 = Model.anIntArray1676;
			}
			if (i6 < k6) {
				i5 = ai3[i6];
			} else {
				i5 = -1000;
			}
		}
	}

	private void method484(int i) {
		if (Model.aBooleanArray1664[i]) {
			method485(i);
			return;
		}
		int j = facePointsA[i];
		int k = facePointsB[i];
		int l = facePointsC[i];
		Renderer3D.edgeRestricted = Model.aBooleanArray1663[i];
		if (alpha == null) {
			Renderer3D.alpha = 0;
		} else {
			Renderer3D.alpha = alpha[i];
		}
		int i1;
		if (renderTypes == null) {
			i1 = 0;
		} else {
			i1 = renderTypes[i] & 3;
		}
		if (i1 == 0) {
			Renderer3D.drawShadedTriangle(Model.anIntArray1666[j], Model.anIntArray1666[k], Model.anIntArray1666[l], Model.anIntArray1665[j], Model.anIntArray1665[k], Model.anIntArray1665[l], hsl1[i], hsl2[i], hsl3[i]);
			return;
		}
		if (i1 == 1) {
			Renderer3D.drawTriangle(Model.anIntArray1666[j], Model.anIntArray1666[k], Model.anIntArray1666[l], Model.anIntArray1665[j], Model.anIntArray1665[k], Model.anIntArray1665[l], Model.invertedPallete[hsl1[i]]);
			return;
		}
		if (i1 == 2) {
			int j1 = renderTypes[i] >> 2;
			int l1 = texturedFacePointsA[j1];
			int j2 = texturedFacePointsB[j1];
			int l2 = texturedFacePointsC[j1];
			Renderer3D.drawTexturedTriangle(Model.anIntArray1666[j], Model.anIntArray1666[k], Model.anIntArray1666[l], Model.anIntArray1665[j], Model.anIntArray1665[k], Model.anIntArray1665[l], hsl1[i], hsl2[i], hsl3[i], Model.anIntArray1668[l1], Model.anIntArray1668[j2], Model.anIntArray1668[l2], Model.anIntArray1669[l1], Model.anIntArray1669[j2], Model.anIntArray1669[l2], Model.anIntArray1670[l1], Model.anIntArray1670[j2], Model.anIntArray1670[l2], colors[i]);
			return;
		}
		if (i1 == 3) {
			int k1 = renderTypes[i] >> 2;
			int i2 = texturedFacePointsA[k1];
			int k2 = texturedFacePointsB[k1];
			int i3 = texturedFacePointsC[k1];
			Renderer3D.drawTexturedTriangle(Model.anIntArray1666[j], Model.anIntArray1666[k], Model.anIntArray1666[l], Model.anIntArray1665[j], Model.anIntArray1665[k], Model.anIntArray1665[l], hsl1[i], hsl1[i], hsl1[i], Model.anIntArray1668[i2], Model.anIntArray1668[k2], Model.anIntArray1668[i3], Model.anIntArray1669[i2], Model.anIntArray1669[k2], Model.anIntArray1669[i3], Model.anIntArray1670[i2], Model.anIntArray1670[k2], Model.anIntArray1670[i3], colors[i]);
		}
	}

	private void method485(int i) {
		int j = Renderer3D.middleX;
		int k = Renderer3D.middleY;
		int l = 0;
		int i1 = facePointsA[i];
		int j1 = facePointsB[i];
		int k1 = facePointsC[i];
		int l1 = Model.anIntArray1670[i1];
		int i2 = Model.anIntArray1670[j1];
		int j2 = Model.anIntArray1670[k1];
		if (l1 >= 50) {
			Model.anIntArray1678[l] = Model.anIntArray1665[i1];
			Model.anIntArray1679[l] = Model.anIntArray1666[i1];
			Model.anIntArray1680[l++] = hsl1[i];
		} else {
			int k2 = Model.anIntArray1668[i1];
			int k3 = Model.anIntArray1669[i1];
			int k4 = hsl1[i];
			if (j2 >= 50) {
				int k5 = (50 - l1) * Model.invertedColors[j2 - l1];
				Model.anIntArray1678[l] = j + (k2 + ((Model.anIntArray1668[k1] - k2) * k5 >> 16) << 9) / 50;
				Model.anIntArray1679[l] = k + (k3 + ((Model.anIntArray1669[k1] - k3) * k5 >> 16) << 9) / 50;
				Model.anIntArray1680[l++] = k4 + ((hsl3[i] - k4) * k5 >> 16);
			}
			if (i2 >= 50) {
				int l5 = (50 - l1) * Model.invertedColors[i2 - l1];
				Model.anIntArray1678[l] = j + (k2 + ((Model.anIntArray1668[j1] - k2) * l5 >> 16) << 9) / 50;
				Model.anIntArray1679[l] = k + (k3 + ((Model.anIntArray1669[j1] - k3) * l5 >> 16) << 9) / 50;
				Model.anIntArray1680[l++] = k4 + ((hsl2[i] - k4) * l5 >> 16);
			}
		}
		if (i2 >= 50) {
			Model.anIntArray1678[l] = Model.anIntArray1665[j1];
			Model.anIntArray1679[l] = Model.anIntArray1666[j1];
			Model.anIntArray1680[l++] = hsl2[i];
		} else {
			int l2 = Model.anIntArray1668[j1];
			int l3 = Model.anIntArray1669[j1];
			int l4 = hsl2[i];
			if (l1 >= 50) {
				int i6 = (50 - i2) * Model.invertedColors[l1 - i2];
				Model.anIntArray1678[l] = j + (l2 + ((Model.anIntArray1668[i1] - l2) * i6 >> 16) << 9) / 50;
				Model.anIntArray1679[l] = k + (l3 + ((Model.anIntArray1669[i1] - l3) * i6 >> 16) << 9) / 50;
				Model.anIntArray1680[l++] = l4 + ((hsl1[i] - l4) * i6 >> 16);
			}
			if (j2 >= 50) {
				int j6 = (50 - i2) * Model.invertedColors[j2 - i2];
				Model.anIntArray1678[l] = j + (l2 + ((Model.anIntArray1668[k1] - l2) * j6 >> 16) << 9) / 50;
				Model.anIntArray1679[l] = k + (l3 + ((Model.anIntArray1669[k1] - l3) * j6 >> 16) << 9) / 50;
				Model.anIntArray1680[l++] = l4 + ((hsl3[i] - l4) * j6 >> 16);
			}
		}
		if (j2 >= 50) {
			Model.anIntArray1678[l] = Model.anIntArray1665[k1];
			Model.anIntArray1679[l] = Model.anIntArray1666[k1];
			Model.anIntArray1680[l++] = hsl3[i];
		} else {
			int i3 = Model.anIntArray1668[k1];
			int i4 = Model.anIntArray1669[k1];
			int i5 = hsl3[i];
			if (i2 >= 50) {
				int k6 = (50 - j2) * Model.invertedColors[i2 - j2];
				Model.anIntArray1678[l] = j + (i3 + ((Model.anIntArray1668[j1] - i3) * k6 >> 16) << 9) / 50;
				Model.anIntArray1679[l] = k + (i4 + ((Model.anIntArray1669[j1] - i4) * k6 >> 16) << 9) / 50;
				Model.anIntArray1680[l++] = i5 + ((hsl2[i] - i5) * k6 >> 16);
			}
			if (l1 >= 50) {
				int l6 = (50 - j2) * Model.invertedColors[l1 - j2];
				Model.anIntArray1678[l] = j + (i3 + ((Model.anIntArray1668[i1] - i3) * l6 >> 16) << 9) / 50;
				Model.anIntArray1679[l] = k + (i4 + ((Model.anIntArray1669[i1] - i4) * l6 >> 16) << 9) / 50;
				Model.anIntArray1680[l++] = i5 + ((hsl1[i] - i5) * l6 >> 16);
			}
		}
		int j3 = Model.anIntArray1678[0];
		int j4 = Model.anIntArray1678[1];
		int j5 = Model.anIntArray1678[2];
		int i7 = Model.anIntArray1679[0];
		int j7 = Model.anIntArray1679[1];
		int k7 = Model.anIntArray1679[2];
		if ((j3 - j4) * (k7 - j7) - (i7 - j7) * (j5 - j4) > 0) {
			Renderer3D.edgeRestricted = false;
			if (l == 3) {
				if ((j3 < 0) || (j4 < 0) || (j5 < 0) || (j3 > Renderer2D.endX) || (j4 > Renderer2D.endX) || (j5 > Renderer2D.endX)) {
					Renderer3D.edgeRestricted = true;
				}
				int l7;
				if (renderTypes == null) {
					l7 = 0;
				} else {
					l7 = renderTypes[i] & 3;
				}
				if (l7 == 0) {
					Renderer3D.drawShadedTriangle(i7, j7, k7, j3, j4, j5, Model.anIntArray1680[0], Model.anIntArray1680[1], Model.anIntArray1680[2]);
				} else if (l7 == 1) {
					Renderer3D.drawTriangle(i7, j7, k7, j3, j4, j5, Model.invertedPallete[hsl1[i]]);
				} else if (l7 == 2) {
					int j8 = renderTypes[i] >> 2;
					int k9 = texturedFacePointsA[j8];
					int k10 = texturedFacePointsB[j8];
					int k11 = texturedFacePointsC[j8];
					Renderer3D.drawTexturedTriangle(i7, j7, k7, j3, j4, j5, Model.anIntArray1680[0], Model.anIntArray1680[1], Model.anIntArray1680[2], Model.anIntArray1668[k9], Model.anIntArray1668[k10], Model.anIntArray1668[k11], Model.anIntArray1669[k9], Model.anIntArray1669[k10], Model.anIntArray1669[k11], Model.anIntArray1670[k9], Model.anIntArray1670[k10], Model.anIntArray1670[k11], colors[i]);
				} else if (l7 == 3) {
					int k8 = renderTypes[i] >> 2;
					int l9 = texturedFacePointsA[k8];
					int l10 = texturedFacePointsB[k8];
					int l11 = texturedFacePointsC[k8];
					Renderer3D.drawTexturedTriangle(i7, j7, k7, j3, j4, j5, hsl1[i], hsl1[i], hsl1[i], Model.anIntArray1668[l9], Model.anIntArray1668[l10], Model.anIntArray1668[l11], Model.anIntArray1669[l9], Model.anIntArray1669[l10], Model.anIntArray1669[l11], Model.anIntArray1670[l9], Model.anIntArray1670[l10], Model.anIntArray1670[l11], colors[i]);
				}
			}
			if (l == 4) {
				if ((j3 < 0) || (j4 < 0) || (j5 < 0) || (j3 > Renderer2D.endX) || (j4 > Renderer2D.endX) || (j5 > Renderer2D.endX) || (Model.anIntArray1678[3] < 0) || (Model.anIntArray1678[3] > Renderer2D.endX)) {
					Renderer3D.edgeRestricted = true;
				}
				int i8;
				if (renderTypes == null) {
					i8 = 0;
				} else {
					i8 = renderTypes[i] & 3;
				}
				if (i8 == 0) {
					Renderer3D.drawShadedTriangle(i7, j7, k7, j3, j4, j5, Model.anIntArray1680[0], Model.anIntArray1680[1], Model.anIntArray1680[2]);
					Renderer3D.drawShadedTriangle(i7, k7, Model.anIntArray1679[3], j3, j5, Model.anIntArray1678[3], Model.anIntArray1680[0], Model.anIntArray1680[2], Model.anIntArray1680[3]);
					return;
				}
				if (i8 == 1) {
					int l8 = Model.invertedPallete[hsl1[i]];
					Renderer3D.drawTriangle(i7, j7, k7, j3, j4, j5, l8);
					Renderer3D.drawTriangle(i7, k7, Model.anIntArray1679[3], j3, j5, Model.anIntArray1678[3], l8);
					return;
				}
				if (i8 == 2) {
					int i9 = renderTypes[i] >> 2;
					int i10 = texturedFacePointsA[i9];
					int i11 = texturedFacePointsB[i9];
					int i12 = texturedFacePointsC[i9];
					Renderer3D.drawTexturedTriangle(i7, j7, k7, j3, j4, j5, Model.anIntArray1680[0], Model.anIntArray1680[1], Model.anIntArray1680[2], Model.anIntArray1668[i10], Model.anIntArray1668[i11], Model.anIntArray1668[i12], Model.anIntArray1669[i10], Model.anIntArray1669[i11], Model.anIntArray1669[i12], Model.anIntArray1670[i10], Model.anIntArray1670[i11], Model.anIntArray1670[i12], colors[i]);
					Renderer3D.drawTexturedTriangle(i7, k7, Model.anIntArray1679[3], j3, j5, Model.anIntArray1678[3], Model.anIntArray1680[0], Model.anIntArray1680[2], Model.anIntArray1680[3], Model.anIntArray1668[i10], Model.anIntArray1668[i11], Model.anIntArray1668[i12], Model.anIntArray1669[i10], Model.anIntArray1669[i11], Model.anIntArray1669[i12], Model.anIntArray1670[i10], Model.anIntArray1670[i11], Model.anIntArray1670[i12], colors[i]);
					return;
				}
				if (i8 == 3) {
					int j9 = renderTypes[i] >> 2;
					int j10 = texturedFacePointsA[j9];
					int j11 = texturedFacePointsB[j9];
					int j12 = texturedFacePointsC[j9];
					Renderer3D.drawTexturedTriangle(i7, j7, k7, j3, j4, j5, hsl1[i], hsl1[i], hsl1[i], Model.anIntArray1668[j10], Model.anIntArray1668[j11], Model.anIntArray1668[j12], Model.anIntArray1669[j10], Model.anIntArray1669[j11], Model.anIntArray1669[j12], Model.anIntArray1670[j10], Model.anIntArray1670[j11], Model.anIntArray1670[j12], colors[i]);
					Renderer3D.drawTexturedTriangle(i7, k7, Model.anIntArray1679[3], j3, j5, Model.anIntArray1678[3], hsl1[i], hsl1[i], hsl1[i], Model.anIntArray1668[j10], Model.anIntArray1668[j11], Model.anIntArray1668[j12], Model.anIntArray1669[j10], Model.anIntArray1669[j11], Model.anIntArray1669[j12], Model.anIntArray1670[j10], Model.anIntArray1670[j11], Model.anIntArray1670[j12], colors[i]);
				}
			}
		}
	}

	private boolean method486(int i, int j, int k, int l, int i1, int j1, int k1, int l1) {
		if ((j < k) && (j < l) && (j < i1)) {
			return false;
		}
		if ((j > k) && (j > l) && (j > i1)) {
			return false;
		}
		return !((i < j1) && (i < k1) && (i < l1)) && ((i <= j1) || (i <= k1) || (i <= l1));
	}
}